package com.summer.core.container;

import javax.servlet.http.HttpSessionBindingEvent;
import javax.servlet.http.HttpSessionBindingListener;

import com.taobao.api.domain.User;
import com.taobao.api.domain.UserInfo;



/**
 * 为了避免操作session,将保存在session中的相关数据保存该对象中,同时为以后的优化提供可能
 * @author dlc
 * @CreateDate 2007-12-20
 */
public class SessionContainer implements HttpSessionBindingListener {

    private String sessionid;
    private UserContext userContext;
    private User user;

    public SessionContainer() {
        super();
        initialize();
    }
    
    public void valueBound(HttpSessionBindingEvent event) {
        //do nothing
    }

    public void valueUnbound(HttpSessionBindingEvent event) {
        cleanUp();
    }
    
    private void initialize() {
        this.userContext = new UserContext();
    }
    
    public void cleanUp() {
    	this.sessionid = null;
    	this.userContext.cleanUp();
    	this.userContext = null;
    	this.user = null;
    }
    
	public String getSessionid() {
		return sessionid;
	}
	public void setSessionid(String sessionid) {
		this.sessionid = sessionid;
	}
	public UserContext getUserContext() {
		return userContext;
	}
	public void setUserContext(UserContext userContext) {
		this.userContext = userContext;
	}
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	
}
